package com.ykt.model;

import com.jfinal.plugin.activerecord.Page;

import java.util.List;
import java.util.Map;

/**
 * @author long.hua
 * @version 1.0.0
 * @since 2016-04-17 13:34
 */
public class ShopCategory extends BaseModel<ShopCategory> {

    private static final long serialVersionUID = 1L;

    public static final String pid = "pid";
    public static final String icon = "icon";
    public static final String market_id = "market_id";
    public static final String seq = "seq";

    public static final ShopCategory dao = new ShopCategory();


    @Override
    public Page<ShopCategory> paginate(int pageNumber, int rows, Map<String, String> paramMap) {
        String select = "SELECT c.*, m.name marketName ";
        String exceptSelect = " FROM shop_category c left join market m on c.market_id=m.id ";
        String sqlOrderBy = " ORDER BY c.seq ";
        paramMap.put(OB, sqlOrderBy);
        return this.paginate(select, exceptSelect, pageNumber, rows, paramMap);
    }


    public List<ShopCategory> findByMarketById(int marketId, int pid) {
        String sql = "select * from shop_category c where market_id=? and pid=? order by c.seq";
        return this.find(sql, marketId, pid);
    }
}
